Telegram Group & Telegram Channel
Сегодня я покажу вам, как быстро разрулить хаос в проекте с кастомным фреймворком, где нет нормального логирования.

Ситуация: клиент дал старый проект, ошибок — куча, но логов нет вообще. В коде try-catch, а в catch — пусто. Что делать?

Вот мой быстрый чеклист, который спасал не раз:


1. Глобальный обработчик ошибок и исключений


set_error_handler(function ($errno, $errstr, $errfile, $errline) {
error_log("[PHP ERROR] $errstr in $errfile:$errline");
return false;
});

set_exception_handler(function (Throwable $e) {
error_log("[UNCAUGHT EXCEPTION] " . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine());
});


Добавил в index.php, и уже вижу, что именно валится.


2. Простой логгер на каждый чих

Создал файл logger.php:


function log_debug($msg) {
file_put_contents(__DIR__.'/debug.log', date('[Y-m-d H:i:s] ') . $msg . PHP_EOL, FILE_APPEND);
}


В нужных местах пишу log_debug('что-то случилось');. Дёшево и сердито, зато работает.


3. Прокинул заголовки и запросы

В самых первых строках запроса:


log_debug("REQUEST: " . $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI']);
log_debug("HEADERS: " . json_encode(getallheaders()));
log_debug("POST: " . json_encode($_POST));


Теперь видно, с чем именно клиент ломает мой старый код.


Не всегда есть время подтягивать Monolog и делать всё красиво. Иногда нужно быстро найти, где горит — и потушить. А уже потом наводить красоту.

А вы как действуете в таких ситуациях? Есть свои приёмы?

👉 @php_lib



tg-me.com/php_lib/764
Create:
Last Update:

Сегодня я покажу вам, как быстро разрулить хаос в проекте с кастомным фреймворком, где нет нормального логирования.

Ситуация: клиент дал старый проект, ошибок — куча, но логов нет вообще. В коде try-catch, а в catch — пусто. Что делать?

Вот мой быстрый чеклист, который спасал не раз:


1. Глобальный обработчик ошибок и исключений


set_error_handler(function ($errno, $errstr, $errfile, $errline) {
error_log("[PHP ERROR] $errstr in $errfile:$errline");
return false;
});

set_exception_handler(function (Throwable $e) {
error_log("[UNCAUGHT EXCEPTION] " . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine());
});


Добавил в index.php, и уже вижу, что именно валится.


2. Простой логгер на каждый чих

Создал файл logger.php:


function log_debug($msg) {
file_put_contents(__DIR__.'/debug.log', date('[Y-m-d H:i:s] ') . $msg . PHP_EOL, FILE_APPEND);
}


В нужных местах пишу log_debug('что-то случилось');. Дёшево и сердито, зато работает.


3. Прокинул заголовки и запросы

В самых первых строках запроса:


log_debug("REQUEST: " . $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI']);
log_debug("HEADERS: " . json_encode(getallheaders()));
log_debug("POST: " . json_encode($_POST));


Теперь видно, с чем именно клиент ломает мой старый код.


Не всегда есть время подтягивать Monolog и делать всё красиво. Иногда нужно быстро найти, где горит — и потушить. А уже потом наводить красоту.

А вы как действуете в таких ситуациях? Есть свои приёмы?

👉 @php_lib

BY Библиотека PHP программиста 👨🏼‍💻👩‍💻




Share with your friend now:
tg-me.com/php_lib/764

View MORE
Open in Telegram


Библиотека PHP программиста ‍‍ Telegram | DID YOU KNOW?

Date: |

The SSE was the first modern stock exchange to open in China, with trading commencing in 1990. It has now grown to become the largest stock exchange in Asia and the third-largest in the world by market capitalization, which stood at RMB 50.6 trillion (US$7.8 trillion) as of September 2021. Stocks (both A-shares and B-shares), bonds, funds, and derivatives are traded on the exchange. The SEE has two trading boards, the Main Board and the Science and Technology Innovation Board, the latter more commonly known as the STAR Market. The Main Board mainly hosts large, well-established Chinese companies and lists both A-shares and B-shares.

Telegram and Signal Havens for Right-Wing Extremists

Since the violent storming of Capitol Hill and subsequent ban of former U.S. President Donald Trump from Facebook and Twitter, the removal of Parler from Amazon’s servers, and the de-platforming of incendiary right-wing content, messaging services Telegram and Signal have seen a deluge of new users. In January alone, Telegram reported 90 million new accounts. Its founder, Pavel Durov, described this as “the largest digital migration in human history.” Signal reportedly doubled its user base to 40 million people and became the most downloaded app in 70 countries. The two services rely on encryption to protect the privacy of user communication, which has made them popular with protesters seeking to conceal their identities against repressive governments in places like Belarus, Hong Kong, and Iran. But the same encryption technology has also made them a favored communication tool for criminals and terrorist groups, including al Qaeda and the Islamic State.

Библиотека PHP программиста ‍‍ from jp


Telegram Библиотека PHP программиста 👨🏼‍💻👩‍💻
FROM USA